﻿using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using YArchitech.LIB;

namespace YArchitech.Plumbing
{
	public partial class FormDrainEquivalent : System.Windows.Forms.Form
	{
		public double DDrainageFlow
		{
			get
			{
				return this.dDrainageFlow;
			}
			set
			{
				this.dDrainageFlow = value;
			}
		}

		public double DEquivalent
		{
			get
			{
				return this.dEquivalent;
			}
			set
			{
				this.dEquivalent = value;
			}
		}

		public FormDrainEquivalent()
		{
			this.InitializeComponent();
			new YJKProcessTools().ShowInTaskbarChange(this);
			base.Icon = Resource.YArchitechIcon;
			this.sqlHelper = new SQLiteDataBaseHelper(Path.Combine(Product.DataLocation, "HYBIMSPACE.db3"));
		}

		private void FormDrainEquivalent_Load(object sender, EventArgs e)
		{
			DataTable dataSource = SQLiteDataOperate.ExecQuery("select Name as '卫生洁具名称', DrainageFlow as '排水流量(L/s)', Equivalent as '当量', Diameter as '排水管管径(mm)' from EquivalentDrainage");
			this.dataGridView.DataSource = dataSource;
			this.dataGridView.Columns[0].Width = 150;
			this.dataGridView.Columns[2].Width = 80;
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			if (this.dataGridView.CurrentRow != null)
			{
				this.DDrainageFlow = double.Parse(this.dataGridView.CurrentRow.Cells[1].Value.ToString());
				this.DEquivalent = double.Parse(this.dataGridView.CurrentRow.Cells[2].Value.ToString());
			}
			base.DialogResult = DialogResult.OK;
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private SQLiteDataBaseHelper sqlHelper;

		private double dDrainageFlow;

		private double dEquivalent;
	}
}
